package com.sx.zongzhi.presenter;

import android.content.Context;

import com.sx.zongzhi.modle.ApiManager;
import com.sx.zongzhi.modle.HeadParamBean;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.utils.BaseUtil;
import com.sx.zongzhi.view.CommentView;

import java.util.Map;

/**添加非公有制经济组织
 * Created by admin on 2017/12/8.
 */

public class AddEconomicOrganizationPest {
    private CommentView commentView;

    /**
     *
     newEconomicOrganization.organization.id	是	string	所属网格id
     newEconomicOrganization.residence	是	string	企业地址
     newEconomicOrganization.name	是	string	企业名称
     newEconomicOrganization.style.id	是	string	企业类别id(字典项名称:新经济组织类别)
     newEconomicOrganization.enterpriseMobile	是	string	企业手机号码(enterpriseMobile和enterpriseTelephone至少填入一项)
     newEconomicOrganization.enterpriseTelephone	是	string	企业电话号码(enterpriseMobile和enterpriseTelephone至少填入一项)
     newEconomicOrganization.isDangerousEnterprise	是	boolean	是否危化企业
     newEconomicOrganization.chiefCardType.id	是	string	法人代表人证件代码id(字典项类型:证件代码)
     newEconomicOrganization.cardNo	是	string	法人代表人证件号码
     newEconomicOrganization.chief	是	string	法人代表人姓名
     newEconomicOrganization.chiefSafe	是	string	治保负责人姓名
     newEconomicOrganization.telephone	是	string	法人代表人电话号码(telephone和mobileNumber至少填入一项)
     newEconomicOrganization.mobileNumber	是	string	法人代表人手机号码(telephone和mobileNumber至少填入一项)
     newEconomicOrganization.mobileNumberSafe	是	string	治保负责人手机号码(mobileNumberSafe和telephoneSafe至少填入一项)
     newEconomicOrganization.telephoneSafe	是	string	治保负责人电话号码(mobileNumberSafe和telephoneSafe至少填入一项)
     newEconomicOrganization.licenseNumber	是	string	工商执照注册号（统一社会信用代码）
     newEconomicOrganization.isHaveOrganizationCondition	是	string	是否具备建立中共党组织条件
     newEconomicOrganization.isHaveOrganization	是	string	是否有中共党组织
     newEconomicOrganization.isHaveGuild	是	string	是否有工会
     newEconomicOrganization.isHaveGroup	是	string	是否有共青团组织
     newEconomicOrganization.isHaveWomenFederation	是	string	是否有妇联组织
     newEconomicOrganization.employeeNumber	是	int	员工数量
     newEconomicOrganization.partyMemberNumber	是	int	中共党员数量
     newEconomicOrganization.theMemeberOfGuild	是	int	工会成员数量
     newEconomicOrganization.theMemeberOfWomenFederation	是	int	妇女数量
     newEconomicOrganization.theMemeberOfGroup	是	int	共青团员数量
     newEconomicOrganization.attentionExtent.id	是	string	关注程度id(字典项名称:社会关注程度)
     newEconomicOrganization.dangerType.id	是	string	安全隐患类型id(字典项名称:安全隐患类型)
     file.path	否	string	图片路径
     newEconomicOrganization.longitude	否	string	经度
     newEconomicOrganization.latitude	否	string	纬度

     * @param commentView
     */
    public AddEconomicOrganizationPest(CommentView commentView) {
        this.commentView=commentView;
    }
    //添加
    public void addAddEconomicOrganization(Context context,String orgId,String residence,
                                           String name,String styleId,String enterpriseMobile,
                                           String enterpriseTelephone,boolean isDangerousEnterprise ,
                                           String chiefCardTypeId,String cardNo,String chief,String chiefSafe,
                                           String telephone,String mobileNumber,String mobileNumberSafe,
                                           String telephoneSafe,String licenseNumber,
                                           boolean isHaveOrganizationCondition,boolean isHaveOrganization,
                                           boolean isHaveGuild,boolean isHaveGroup,boolean isHaveWomenFederation,
                                           String employeeNumber,String partyMemberNumber,String theMemeberOfGuild,
                                           String theMemeberOfWomenFederation,String theMemeberOfGroup,
                                           String attentionExtentId,String dangerTypeId,String filePath,double longitude,double latitude){
        Map<String,Object> map = HeadParamBean.getHead(context);
        map.put("orgId", orgId);
        map.put("newEconomicOrganization.residence", residence);
        map.put("newEconomicOrganization.name", name);
        map.put("newEconomicOrganization.style.id", styleId);
        map.put("newEconomicOrganization.enterpriseMobile", enterpriseMobile);
        map.put("newEconomicOrganization.enterpriseTelephone", enterpriseTelephone);
        map.put("newEconomicOrganization.isDangerousEnterprise", isDangerousEnterprise);
        map.put("newEconomicOrganization.chiefCardType.id", chiefCardTypeId);
        map.put("newEconomicOrganization.cardNo", cardNo);
        map.put("newEconomicOrganization.chief", chief);
        map.put("newEconomicOrganization.chiefSafe", chiefSafe);
        map.put("newEconomicOrganization.telephone", telephone);
        map.put("newEconomicOrganization.mobileNumber", mobileNumber);
        map.put("newEconomicOrganization.mobileNumberSafe", mobileNumberSafe);
        map.put("newEconomicOrganization.telephoneSafe", telephoneSafe);
        map.put("newEconomicOrganization.licenseNumber", licenseNumber);
        map.put("newEconomicOrganization.isHaveOrganizationCondition", isHaveOrganizationCondition);
        map.put("newEconomicOrganization.isHaveOrganization", isHaveOrganization);
        map.put("newEconomicOrganization.isHaveGuild", isHaveGuild);
        map.put("newEconomicOrganization.isHaveGroup", isHaveGroup);
        map.put("newEconomicOrganization.isHaveWomenFederation", isHaveWomenFederation);
        map.put("newEconomicOrganization.employeeNumber", employeeNumber);
        map.put("newEconomicOrganization.partyMemberNumber", partyMemberNumber);
        map.put("newEconomicOrganization.theMemeberOfGuild", theMemeberOfGuild);
        map.put("newEconomicOrganization.theMemeberOfWomenFederation", theMemeberOfWomenFederation);
        map.put("newEconomicOrganization.theMemeberOfGroup", theMemeberOfGroup);
        map.put("newEconomicOrganization.attentionExtent.id", attentionExtentId);
        map.put("newEconomicOrganization.dangerType.id", dangerTypeId);
        if (!BaseUtil.isEmpty(filePath)){
            map.put("file.path",filePath);
        }
//        map.put("newEconomicOrganization.longitude", longitude);
//        map.put("newEconomicOrganization.latitude", latitude);
        new ApiManager().addEconomicOrganization(map, new BaseCallBack<BaseResult<Boolean>>() {
            @Override
            public void onSuccess(BaseResult<Boolean> response) {
                commentView.commentSuccess(response.getData());
            }
            @Override
            public void onFailures(String message) {
                commentView.showError(message);
            }
        });
    }
    //修改
    public void updateEconomicOrganization(Context context,String id,String orgId,String residence,
                                           String name,String styleId,String enterpriseMobile,
                                           String enterpriseTelephone,boolean isDangerousEnterprise ,
                                           String chiefCardTypeId,String cardNo,String chief,String chiefSafe,
                                           String telephone,String mobileNumber,String mobileNumberSafe,
                                           String telephoneSafe,String licenseNumber,
                                           boolean isHaveOrganizationCondition,boolean isHaveOrganization,
                                           boolean isHaveGuild,boolean isHaveGroup,boolean isHaveWomenFederation,
                                           String employeeNumber,String partyMemberNumber,String theMemeberOfGuild,
                                           String theMemeberOfWomenFederation,String theMemeberOfGroup,
                                           String attentionExtentId,String dangerTypeId,String filePath,double longitude,double latitude){
        Map<String,Object> map = HeadParamBean.getHead(context);
        map.put("newEconomicOrganization.id", id);
        map.put("orgId", orgId);
        map.put("newEconomicOrganization.residence", residence);
        map.put("newEconomicOrganization.name", name);
        map.put("newEconomicOrganization.style.id", styleId);
        map.put("newEconomicOrganization.enterpriseMobile", enterpriseMobile);
        map.put("newEconomicOrganization.enterpriseTelephone", enterpriseTelephone);
        map.put("newEconomicOrganization.isDangerousEnterprise", isDangerousEnterprise);
        map.put("newEconomicOrganization.chiefCardType.id", chiefCardTypeId);
        map.put("newEconomicOrganization.cardNo", cardNo);
        map.put("newEconomicOrganization.chief", chief);
        map.put("newEconomicOrganization.chiefSafe", chiefSafe);
        map.put("newEconomicOrganization.telephone", telephone);
        map.put("newEconomicOrganization.mobileNumber", mobileNumber);
        map.put("newEconomicOrganization.mobileNumberSafe", mobileNumberSafe);
        map.put("newEconomicOrganization.telephoneSafe", telephoneSafe);
        map.put("newEconomicOrganization.licenseNumber", licenseNumber);
        map.put("newEconomicOrganization.isHaveOrganizationCondition", isHaveOrganizationCondition);
        map.put("newEconomicOrganization.isHaveOrganization", isHaveOrganization);
        map.put("newEconomicOrganization.isHaveGuild", isHaveGuild);
        map.put("newEconomicOrganization.isHaveGroup", isHaveGroup);
        map.put("newEconomicOrganization.isHaveWomenFederation", isHaveWomenFederation);
        map.put("newEconomicOrganization.employeeNumber", employeeNumber);
        map.put("newEconomicOrganization.partyMemberNumber", partyMemberNumber);
        map.put("newEconomicOrganization.theMemeberOfGuild", theMemeberOfGuild);
        map.put("newEconomicOrganization.theMemeberOfWomenFederation", theMemeberOfWomenFederation);
        map.put("newEconomicOrganization.theMemeberOfGroup", theMemeberOfGroup);
        map.put("newEconomicOrganization.attentionExtent.id", attentionExtentId);
        map.put("newEconomicOrganization.dangerType.id", dangerTypeId);
        if (!BaseUtil.isEmpty(filePath)){
            map.put("file.path",filePath);
        }
//        map.put("newEconomicOrganization.longitude", longitude);
//        map.put("newEconomicOrganization.latitude", latitude);
        new ApiManager().updateEconomicOrganization(map, new BaseCallBack<BaseResult<Boolean>>() {
            @Override
            public void onSuccess(BaseResult<Boolean> response) {
                commentView.commentSuccess(response.getData());
            }
            @Override
            public void onFailures(String message) {
                commentView.showError(message);
            }
        });
    }


}
